package com.lcxw.hxzb.friendcircle.project.system.controller;

import com.lcxw.hxzb.friendcircle.framework.web.controller.BaseController;
import com.lcxw.hxzb.friendcircle.framework.web.domain.AjaxResult;
import com.lcxw.hxzb.friendcircle.framework.web.page.TableDataInfo;
import com.lcxw.hxzb.friendcircle.project.system.domain.YwpdGame;
import com.lcxw.hxzb.friendcircle.project.system.service.IYwpdDistrictService;
import com.lcxw.hxzb.friendcircle.project.system.service.IYwpdGameService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 陪玩游戏类型Controller
 * 
 * @author ruoyi
 * @date 2020-09-15
 */
@RestController
@Api(tags = "陪玩游戏类型Controller")
@RequestMapping("/system/game")
public class YwpdManageController extends BaseController
{
    @Autowired
    private IYwpdGameService ywpdGameService;

    @Autowired
    private IYwpdDistrictService ywpdDistrictService;
    /**
     * 查询陪玩游戏类型列表
     */
    @GetMapping("/list")
    public TableDataInfo list(YwpdGame ywpdGame)
    {
        startPage();
        List<YwpdGame> list = ywpdGameService.selectYwpdGameList(ywpdGame);
        return getDataTable(list);
    }

    /**
     * 新增陪玩游戏类型
     */
    @PostMapping
    public AjaxResult add(@RequestBody YwpdGame ywpdGame)
    {
        return toAjax(ywpdGameService.insertYwpdGame(ywpdGame));
    }


    /**
     * 删除陪玩游戏类型
     */
    @DeleteMapping("/{gameIds}")
    public AjaxResult remove(@PathVariable Long[] gameIds)
    {
        return toAjax(ywpdGameService.deleteYwpdGameByIds(gameIds));
    }

    /**
     * 获取陪玩游戏类型详细信息
     */
    @GetMapping(value = "/{gameId}")
    public AjaxResult getInfo(@PathVariable("gameId") Long gameId)
    {
        AjaxResult ajax = AjaxResult.success(ywpdGameService.selectYwpdGameById(gameId));
        ajax.put("districtIds", ywpdDistrictService.selectDistrictByGameId(gameId));
        return ajax;
    }


    /**
     * 修改陪玩游戏类型
     */
    @PutMapping
    public AjaxResult edit(@RequestBody YwpdGame ywpdGame)
    {
        return toAjax(ywpdGameService.updateYwpdGame(ywpdGame));
    }

}
